﻿
<%@ Page Inherits="Microsoft.Crm.Application.Controls.AppPage, Microsoft.Crm.Application.Components.Application" %>
<%@ Register TagPrefix="cnt" Namespace="Microsoft.Crm.Application.Controls" Assembly="Microsoft.Crm.Application.Components.Application" %>
<html>
<head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312"/>
<title>Change Field Properties</title>
<link rel="stylesheet" type="text/css" href="/_common/styles/global.css">
<link rel="stylesheet" type="text/css" href="/_common/styles/select.css">
<link rel="stylesheet" type="text/css" href="/_nav/tabs.css">
<link rel="stylesheet" type="text/css" href="/Tools/PreviewManager/Styles/dialogs.css">
<script language="javascript" src="/_common/scripts/global.js"></script>
<script language="javascript" src="/Tools/PreviewManager/Scripts/objects.js"></script>
<script language="javascript" src="/Tools/PreviewManager/Scripts/dialogs.js"></script>
<script language="javascript">

	var _Spaces;
	var _MaxFields	= 16;
	var oField;

	function window.onload()
	{
		oField = window.dialogArguments.Field;
		
		_Spaces			= window.dialogArguments.Spaces;
		
		document.all.SchemaName.innerHTML = "Schema Name:"  + "&nbsp;&nbsp;" + oField.FieldName;
		document.all.FieldNameDiv.innerHTML = "Field Name:"  + "&nbsp;&nbsp;" + oField.DisplayNames[0].Description;
		document.all.fieldType.innerHTML = "Type:" + "&nbsp;&nbsp;" + oField.DataType;
				
		crmDialog.FieldName.value = oField.FieldName;
		
		if (oField.Span)
		{
			crmDialog.Span[0].checked = true;
		}
		else
		{
			crmDialog.Span[1].checked = true;
		}		
	}
	

	function Ok()
	{			
		//was not checked and it is now and there is no more space
		if ( (!oField.Span) && (crmDialog.Span[0].checked) && (_MaxFields + _Spaces == _MaxFields) )
		{
			alert ( "You don\'t have any more space available in the preview to expand this field." );
		}
		else
		{
			oField	= new FieldObj(
						crmDialog.FieldName.value,
						null,
						null,
						null,
						crmDialog.Span[0].checked,
						null,
						null,
						null
					);

			window.returnValue = oField;

			window.close();
		}
	}
	
</script>
</head>
<body>
	<form name="crmDialog">
		<input type="hidden" name="FieldName">
		<table cellspacing="0" cellpadding="0" width="100%" height="100%">
			<tr>
				<td class="header">
					<div class="header">Change Field Properties</div>
					<div class="headerdesc">Select the layout of this field.</div>
				</td>
			</tr>
			<tr>
				<td class="main" valign="top">
					<table width="100%" height="100%" cellspacing="0" cellpadding="0">
						<tr>
							<td valign="top">
								<table cellpadding="0" cellspacing="5" width="100%" style="table-layout: fixed;">
									<col width="70"><col>
									<tr>
										<td colspan="2"><div id="FieldNameDiv"></td>
									</tr>
									<tr>
										<td colspan="2"><div id="SchemaName"></td>
									</tr>
									<tr>
										<td colspan="2"><div id="fieldType"></td>
									</tr>
								</table>
								<div class="desc" style="padding-bottom: 5px;">
									Select the number of columns the field occupies:
								</div>
								<table cellpadding="0" cellspacing="5" width="100%" style="table-layout: fixed;">
									<col width="15"><col><col width="85" style="text-align: right;">
									<tr>
										<td><input id="SpanTrue" name="Span" type="radio" class="radio"></td>
										<td><label for="SpanTrue">Two columns</label></td>
										<td>
											<table  cellpadding="0" cellspacing="4" width="75" class="example">
												<tr>
													<td class="example">&nbsp;</td>
													<td class="example">&nbsp;</td>
												</tr>
												<tr>
													<td class="example active" colspan="2">&nbsp;</td>
												</tr>
												<tr>
													<td class="example">&nbsp;</td>
													<td class="example">&nbsp;</td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td colspan="3" height="10"></td>
									</tr>
									<tr>
										<td><input id="SpanFalse" name= "Span" type="radio" class="radio"></td>
										<td><label for="SpanFalse">One column</label></td>
										<td>
											<table cellpadding="0" cellspacing="4" width="75" class="example">
												<tr>
													<td class="example">&nbsp;</td>
													<td class="example">&nbsp;</td>
												</tr>
												<tr>
													<td class="example active">&nbsp;</td>
													<td class="example">&nbsp;</td>
												</tr>
												<tr>
													<td class="example">&nbsp;</td>
													<td class="example">&nbsp;</td>
												</tr>
											</table>
										</td>
									</tr>
								</table>								
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td class="buttons">
					<button id="btnDialogOk" onclick="Ok();">OK</button>
					<span>&nbsp;</span>
					<button id="btnDialogCancel" onclick="Cancel();">Cancel</button>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
